package jiggle;

public class QuadraticSpringLaw extends SpringLaw {

	public QuadraticSpringLaw (Graph g, double k) {super (g, k);}		

	@Override
    public double pairwiseWeights (double pref, double curr) {
        //double r = pref  - preferredEdgeLength;
		//return (curr - r) / preferredEdgeLength;
		//return (curr - pref + preferredEdgeLength) / preferredEdgeLength;
		//return 1 + ((curr - pref) / preferredEdgeLength);
		
        //curr = Math.min(curr, 2*preferredEdgeLength);

	    //return 1 + (  Math.max(0,(curr - pref)) / preferredEdgeLength  );
	    return 1 + (  Math.max(0,Math.min(1,(curr - pref)) / preferredEdgeLength)  );
	}
}
